//
//  JunFenQingKuangView.m
//  SchoolHelper
//
//  Created by 任辰东 on 2022/8/26.
//  Copyright © 2022 JSY. All rights reserved.
//

#import "JunFenQingKuangView.h"
#import "ReportCardTitleView.h"

@interface JunFenQingKuangView ()
@property (nonatomic, strong) ReportCardTitleView *titleView;
@property (nonatomic, strong) UIView *containerView;
@property (nonatomic, strong) UILabel *totalLabel;
@property (nonatomic, strong) UILabel *zhengqueLabel;
@property (nonatomic, strong) UILabel *cuowuLabel;
@property (nonatomic, strong) UILabel *gailvLabel;

@property (nonatomic, strong) UILabel *totalMarkLabel;
@property (nonatomic, strong) UILabel *zhengqueMarkLabel;
@property (nonatomic, strong) UILabel *cuowuMarkLabel;
@property (nonatomic, strong) UILabel *gailvMarkLabel;
@end

@implementation JunFenQingKuangView

-(void)configViewWithModel:(ReportCardTiDetailModel *)model
{
    self.totalLabel.text = IsEmpty(model.defen_manfen)?@"无":model.defen_manfen;
    self.zhengqueLabel.text = IsEmpty(model.nianji_junfen)?@"无":model.nianji_junfen;
    self.cuowuLabel.text = IsEmpty(model.banji_junfen)? @"无":model.banji_junfen;
    self.gailvLabel.text = IsEmpty(model.liankao_junfen)?@"无":model.liankao_junfen;
}

-(void)setupViews
{
    self.backgroundColor = UIColorFromHex(kColorWhite);
    [self addSubview:self.titleView];
    [self addSubview:self.containerView];
    [self.containerView addSubview:self.totalLabel];
    [self.containerView addSubview:self.totalMarkLabel];
    [self.containerView addSubview:self.zhengqueLabel];
    [self.containerView addSubview:self.zhengqueMarkLabel];
    [self.containerView addSubview:self.cuowuLabel];
    [self.containerView addSubview:self.cuowuMarkLabel];
    [self.containerView addSubview:self.gailvLabel];
    [self.containerView addSubview:self.gailvMarkLabel];
}

-(void)setupLayout
{
    [self.titleView mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.left.right.equalTo(self);
    }];
    [self.containerView mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(self.titleView.mas_bottom).offset(10);
        make.left.equalTo(self).offset(15);
        make.bottom.right.equalTo(self).offset(-15);
    }];
    
    CGFloat width = (kScreenWidth - 15 *2)/4;
    [self.totalLabel mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(self.containerView).offset(15);
        make.left.equalTo(self.containerView).offset(15);
        make.width.mas_equalTo(width);
    }];
    
    [self.totalMarkLabel mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(self.totalLabel.mas_bottom).offset(5);
        make.left.equalTo(self.containerView).offset(15);
        make.width.mas_equalTo(width);
        make.bottom.equalTo(self.containerView).offset(-15);
    }];
    
    [self.zhengqueLabel mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(self.containerView).offset(15);
        make.left.equalTo(self.totalLabel.mas_right).offset(0);
        make.width.mas_equalTo(width);
    }];
    
    [self.zhengqueMarkLabel mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(self.zhengqueLabel.mas_bottom).offset(5);
        make.left.equalTo(self.totalMarkLabel.mas_right).offset(0);
        make.width.mas_equalTo(width);
        make.bottom.equalTo(self.containerView).offset(-15);
    }];
    
    [self.cuowuLabel mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(self.containerView).offset(15);
        make.left.equalTo(self.zhengqueLabel.mas_right).offset(0);
        make.width.mas_equalTo(width);
    }];
    
    [self.cuowuMarkLabel mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(self.cuowuLabel.mas_bottom).offset(5);
        make.left.equalTo(self.zhengqueMarkLabel.mas_right).offset(0);
        make.width.mas_equalTo(width);
        make.bottom.equalTo(self.containerView).offset(-15);
    }];
    
    [self.gailvLabel mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(self.containerView).offset(15);
        make.left.equalTo(self.cuowuLabel.mas_right).offset(0);
        make.width.mas_equalTo(width);
    }];
    
    [self.gailvMarkLabel mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(self.gailvLabel.mas_bottom).offset(5);
        make.left.equalTo(self.cuowuMarkLabel.mas_right).offset(0);
        make.width.mas_equalTo(width);
        make.bottom.equalTo(self.containerView).offset(-15);
    }];
}

-(ReportCardTitleView *)titleView
{
    if (!_titleView) {
        _titleView = [ReportCardTitleView new];
        [_titleView configViewWithTitle:@"均分情况"];
    }
    return _titleView;
}

-(UIView *)containerView
{
    if (!_containerView) {
        _containerView = [UIView new];
        _containerView.backgroundColor = UIColorFromHex(kColorWhite);
        _containerView.layer.cornerRadius = 5;
        _containerView.layer.masksToBounds = YES;
        _containerView.layer.borderWidth = kOnePixel;
        _containerView.layer.borderColor = UIColorFromHex(kColorLine).CGColor;
    }
    return _containerView;
}

-(UILabel *)totalLabel
{
    if (!_totalLabel) {
        _totalLabel = [UILabel new];
        _totalLabel.textColor = UIColorFromHex(0x000000);
        _totalLabel.font = UIFontSize(15);
        _totalLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _totalLabel;
}

-(UILabel *)zhengqueLabel
{
    if (!_zhengqueLabel) {
        _zhengqueLabel = [UILabel new];
        _zhengqueLabel.textColor = UIColorFromHex(0x000000);
        _zhengqueLabel.font = UIFontSize(15);
        _zhengqueLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _zhengqueLabel;
}

-(UILabel *)cuowuLabel
{
    if (!_cuowuLabel) {
        _cuowuLabel = [UILabel new];
        _cuowuLabel.textColor = UIColorFromHex(0x000000);
        _cuowuLabel.font = UIFontSize(15);
        _cuowuLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _cuowuLabel;
}

-(UILabel *)gailvLabel
{
    if (!_gailvLabel) {
        _gailvLabel = [UILabel new];
        _gailvLabel.textColor = UIColorFromHex(0x000000);
        _gailvLabel.font = UIFontSize(15);
        _gailvLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _gailvLabel;
}

-(UILabel *)totalMarkLabel
{
    if (!_totalMarkLabel) {
        _totalMarkLabel = [UILabel new];
        _totalMarkLabel.text = @"得分/满分";
        _totalMarkLabel.textColor = UIColorFromHex(0x666666);
        _totalMarkLabel.font = UIFontSize(11);
        _totalMarkLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _totalMarkLabel;
}

-(UILabel *)zhengqueMarkLabel
{
    if (!_zhengqueMarkLabel) {
        _zhengqueMarkLabel = [UILabel new];
        _zhengqueMarkLabel.text = @"年级平均分";
        _zhengqueMarkLabel.textColor = UIColorFromHex(0x666666);
        _zhengqueMarkLabel.font = UIFontSize(11);
        _zhengqueMarkLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _zhengqueMarkLabel;
}

-(UILabel *)cuowuMarkLabel
{
    if (!_cuowuMarkLabel) {
        _cuowuMarkLabel = [UILabel new];
        _cuowuMarkLabel.text = @"班级平均分";
        _cuowuMarkLabel.textColor = UIColorFromHex(0x666666);
        _cuowuMarkLabel.font = UIFontSize(11);
        _cuowuMarkLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _cuowuMarkLabel;
}

-(UILabel *)gailvMarkLabel
{
    if (!_gailvMarkLabel) {
        _gailvMarkLabel = [UILabel new];
        _gailvMarkLabel.text = @"联考平均分";
        _gailvMarkLabel.textColor = UIColorFromHex(0x666666);
        _gailvMarkLabel.font = UIFontSize(11);
        _gailvMarkLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _gailvMarkLabel;
}
@end
